<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<link th:href="@{/ajax/libs/summernote/summernote.css}" rel="stylesheet"/>
<link th:href="@{/ajax/libs/summernote/summernote-bs3.css}" rel="stylesheet"/>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-dongtai-add">

			<div class="form-group">	
				<label class="col-sm-3 control-label">标题：</label>
				<div class="col-sm-8">
					<input id="biaoTi" name="biaoTi" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">内容：</label>
				<div class="col-sm-8">
					<input id="context" name="context" type="hidden">
					<div class="summernote"></div>
				</div>
			</div>


		</form>
	</div>
    <div th:include="include::footer"></div>
	<script th:src="@{/ajax/libs/summernote/summernote.min.js}"></script>
	<script th:src="@{/ajax/libs/summernote/summernote-zh-CN.js}"></script>
    <script type="text/javascript">
		var prefix = ctx + "system/dongtai"
		/**
		 * 最新富文本编辑器中华的图片上传功能
		 * 图片显示但是无法保存
		 */
		$('.summernote').summernote({
			height: '220px',
			lang: 'zh-CN',
			onImageUpload:function (files,editor,$editable) {
				var $files = $(files);
				$files.each(function () {
					var file = this;
					var data = new FormData();
					data.append("file",file);
					$.ajax({
						data:data,
						url:ctx + "common/upload",
						cacne:false,
						contentType:false,
						processData:false,
						success:function (response) {
							var imageUrl = response.msg;
							editor.insertImage($editable,ctx+"profile/"+imageUrl,response.fileName);
						}
					})
				})
			}

		});

		$("#form-dongtai-add").validate({
			rules:{
				noticeTitle:{
					required:true,
				}
			}
		});

		function submitHandler() {
			if ($.validate.form()) {
				var sHTML = $('.summernote').summernote('code');
				$("#context").val(sHTML);
				$.operate.save(prefix + "/add", $('#form-dongtai-add').serialize());
			}
		}


	</script>
</body>
</html>
